//
// Created by 25313 on 2025/8/5.
//
class Solution {
public:
    bool isPrime(int n)
    {
        if(n <= 1)
        {
            return false;
        }
        if(n == 2)
        {
            return true;
        }
        if(n % 2 == 0)
        {
            return false;
        }
        for(int i = 3; i <= sqrt(n); i += 2)
        {
            if(n % i == 0)
            {
                return false;
            }
        }
        return true;
    }
    int diagonalPrime(vector<vector<int>>& nums) {
        int size = nums.size();
        int max = 0;
        int i = 0;
        int j = 0;
        for(int t = 0;t < size;t++)
        {
            if(isPrime(nums[i][j]))
            {
                if(nums[i][j] > max)
                    max = nums[i][j];
            }
            i++;
            j++;
        }
        i = 0;
        j = size - 1;
        for(int t = 0; t < size;t++)
        {
            if(isPrime(nums[i][j]))
            {
                if(nums[i][j] > max)
                    max = nums[i][j];
            }
            i++;
            j--;
        }
        return max;
    }
};